from django.db import models

# Create your models here.
class President(models.Model):
    name = models.CharField(max_length=100, verbose_name=u'名称')

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = "班级"
        db_table = 'user_president'

class User(models.Model):
    ROLE = (
        (u'cadre', u'班委'),
        (u'student', u'学生'),
    )
    username = models.CharField(max_length=100, verbose_name=u'账号')
    password = models.CharField(max_length=100, verbose_name=u'密码')
    name = models.CharField(max_length=100, verbose_name=u'名称')
    role = models.CharField(
        max_length=30,null=True,blank=True, verbose_name=u'权限', choices=ROLE)
    president = models.ForeignKey(President, on_delete=models.CASCADE)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = "学生"
        db_table = 'user_user'

class User_Token(models.Model):
    user = models.OneToOneField('User',on_delete=models.CASCADE)
    token = models.CharField(max_length=64)

    class Mete:
        verbose_name_plural = "用户token"
        db_table = 'user_user_token'


    # groups = models.ManyToManyField(Group, related_name='groupUsers')